/*
 * fluorescence is a free, customizable Ultima Online client.
 * Copyright (C) 2011-2012, http://fluorescence-client.org

 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */



#include "unknown.hpp"

#include <net/manager.hpp>

namespace fluo {
namespace net {
namespace packets {

Unknown::Unknown(uint8_t id) : Packet(id) {
    static uint16_t allPacketSizes[256] = {
        0x0068, 0x0005, 0x0007, 0x0000, 0x0002, 0x0005, 0x0005, 0x0007, // 0x00
        0x000F, 0x0005, 0x000B, 0x0007, 0x0000, 0x0003, 0x0000, 0x003D, // 0x08
        0x00D7, 0x0000, 0x0000, 0x000A, 0x0006, 0x0009, 0x0000, 0x0000, // 0x10
        0x0000, 0x0000, 0x0000, 0x0025, 0x0000, 0x0005, 0x0004, 0x0008, // 0x18
        0x0013, 0x0008, 0x0003, 0x001A, 0x0007, 0x0015, 0x0005, 0x0002, // 0x20
        0x0005, 0x0001, 0x0005, 0x0002, 0x0002, 0x0011, 0x000F, 0x000A, // 0x28
        0x0005, 0x0000, 0x0002, 0x0002, 0x000A, 0x028D, 0x0000, 0x0008, // 0x30
        0x0007, 0x0009, 0x0000, 0x0000, 0x0000, 0x0002, 0x0025, 0x0000, // 0x38
        0x00C9, 0x0000, 0x0000, 0x0229, 0x02C9, 0x0005, 0x0000, 0x000B, // 0x40
        0x0049, 0x005D, 0x0005, 0x0009, 0x0000, 0x0000, 0x0006, 0x0002, // 0x48
        0x0000, 0x0000, 0x0000, 0x0002, 0x000C, 0x0001, 0x000B, 0x006E, // 0x50
        0x006A, 0x0000, 0x0000, 0x0004, 0x0002, 0x0049, 0x0000, 0x0031, // 0x58
        0x0005, 0x0009, 0x000F, 0x000D, 0x0001, 0x0004, 0x0000, 0x0015, // 0x60
        0x0000, 0x0000, 0x0003, 0x0009, 0x0013, 0x0003, 0x000E, 0x0000, // 0x68
        0x001C, 0x0000, 0x0005, 0x0002, 0x0000, 0x0023, 0x0010, 0x0011, // 0x70
        0x0000, 0x0009, 0x0000, 0x0002, 0x0000, 0x000D, 0x0002, 0x0000, // 0x78
        0x003E, 0x0000, 0x0002, 0x0027, 0x0045, 0x0002, 0x0000, 0x0000, // 0x80
        0x0042, 0x0000, 0x0000, 0x0000, 0x000B, 0x0000, 0x0000, 0x0000, // 0x88
        0x0013, 0x0041, 0x0000, 0x0063, 0x0000, 0x0009, 0x0000, 0x0002, // 0x90
        0x0000, 0x001A, 0x0000, 0x0102, 0x0135, 0x0033, 0x0000, 0x0000, // 0x98
        0x0003, 0x0009, 0x0009, 0x0009, 0x0095, 0x0000, 0x0000, 0x0004, // 0xA0
        0x0000, 0x0000, 0x0005, 0x0000, 0x0000, 0x0000, 0x0000, 0x000D, // 0xA8
        0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0040, 0x0009, 0x0000, // 0xB0
        0x0000, 0x0005, 0x0006, 0x0009, 0x0003, 0x0000, 0x0000, 0x0000, // 0xB8
        0x0024, 0x0000, 0x0000, 0x0000, 0x0006, 0x00CB, 0x0001, 0x0031, // 0xC0
        0x0002, 0x0006, 0x0006, 0x0007, 0x0000, 0x0001, 0x0000, 0x004E, // 0xC8
        0x0000, 0x0002, 0x0019, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0
        0x0000, 0x010C, 0x0000, 0x0000, 0x0009, 0x0000, 0x0000, 0x0000, // 0xD8
        0x0000, 0x0000, 0x000A, 0x0000, 0x0000, 0x0000, 0x0005, 0x000C, // 0xE0
        0x000D, 0x004B, 0x0003, 0x0000, 0x0000, 0x0000, 0x000A, 0x0015, // 0xE8
        0x0000, 0x0009, 0x0019, 0x0018, 0x0000, 0x0015, 0x0000, 0x0000, // 0xF0
        0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, // 0xF8
    };

    static uint16_t allPacketSizesHS[256] = {
        0x0068, 0x0005, 0x0007, 0x0000, 0x0002, 0x0005, 0x0005, 0x0007, // 0x00
        0x000F, 0x0005, 0x000B, 0x0007, 0x0000, 0x0003, 0x0000, 0x003D, // 0x08
        0x00D7, 0x0000, 0x0000, 0x000A, 0x0006, 0x0009, 0x0000, 0x0000, // 0x10
        0x0000, 0x0000, 0x0000, 0x0025, 0x0000, 0x0005, 0x0004, 0x0008, // 0x18
        0x0013, 0x0008, 0x0003, 0x001A, 0x0009, 0x0015, 0x0005, 0x0002, // 0x20
        0x0005, 0x0001, 0x0005, 0x0002, 0x0002, 0x0011, 0x000F, 0x000A, // 0x28
        0x0005, 0x0000, 0x0002, 0x0002, 0x000A, 0x028D, 0x0000, 0x0008, // 0x30
        0x0007, 0x0009, 0x0000, 0x0000, 0x0000, 0x0002, 0x0025, 0x0000, // 0x38
        0x00C9, 0x0000, 0x0000, 0x0229, 0x02C9, 0x0005, 0x0000, 0x000B, // 0x40
        0x0049, 0x005D, 0x0005, 0x0009, 0x0000, 0x0000, 0x0006, 0x0002, // 0x48
        0x0000, 0x0000, 0x0000, 0x0002, 0x000C, 0x0001, 0x000B, 0x006E, // 0x50
        0x006A, 0x0000, 0x0000, 0x0004, 0x0002, 0x0049, 0x0000, 0x0031, // 0x58
        0x0005, 0x0009, 0x000F, 0x000D, 0x0001, 0x0004, 0x0000, 0x0015, // 0x60
        0x0000, 0x0000, 0x0003, 0x0009, 0x0013, 0x0003, 0x000E, 0x0000, // 0x68
        0x001C, 0x0000, 0x0005, 0x0002, 0x0000, 0x0023, 0x0010, 0x0011, // 0x70
        0x0000, 0x0009, 0x0000, 0x0002, 0x0000, 0x000D, 0x0002, 0x0000, // 0x78
        0x003E, 0x0000, 0x0002, 0x0027, 0x0045, 0x0002, 0x0000, 0x0000, // 0x80
        0x0042, 0x0000, 0x0000, 0x0000, 0x000B, 0x0000, 0x0000, 0x0000, // 0x88
        0x0013, 0x0041, 0x0000, 0x0063, 0x0000, 0x0009, 0x0000, 0x0002, // 0x90
        0x0000, 0x001E, 0x0000, 0x0102, 0x0135, 0x0033, 0x0000, 0x0000, // 0x98
        0x0003, 0x0009, 0x0009, 0x0009, 0x0095, 0x0000, 0x0000, 0x0004, // 0xA0
        0x0000, 0x0000, 0x0005, 0x0000, 0x0000, 0x0000, 0x0000, 0x000D, // 0xA8
        0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0040, 0x0009, 0x0000, // 0xB0
        0x0000, 0x0005, 0x000A, 0x0009, 0x0003, 0x0000, 0x0000, 0x0000, // 0xB8
        0x0024, 0x0000, 0x0000, 0x0000, 0x0006, 0x00CB, 0x0001, 0x0031, // 0xC0
        0x0002, 0x0006, 0x0006, 0x0007, 0x0000, 0x0001, 0x0000, 0x004E, // 0xC8
        0x0000, 0x0002, 0x0019, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0
        0x0000, 0x010C, 0x0000, 0x0000, 0x0009, 0x0000, 0x0000, 0x0000, // 0xD8
        0x0000, 0x0000, 0x000A, 0x0000, 0x0000, 0x0000, 0x0005, 0x000C, // 0xE0
        0x000D, 0x004B, 0x0003, 0x0000, 0x0000, 0x0000, 0x000A, 0x0015, // 0xE8
        0x0000, 0x0009, 0x0019, 0x001A, 0x0000, 0x0015, 0x0000, 0x0000, // 0xF0
        0x006A, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, // 0xF8
    };

    size_ = net::Manager::getSingleton()->getProtocolVersion() >= ProtocolVersion::HS ? allPacketSizesHS[id] : allPacketSizes[id];
}

bool Unknown::read(const int8_t* buf, unsigned int len, unsigned int& index) {
    bool ret = true;

    index = len;

    return ret;
}

}
}
}
